import { useSelector, useDispatch } from "react-redux";

 const useStore = () => {
    const userData = useSelector((state) => state.userData);
    const loading = useSelector((state) => state.loading);
    const collapsed = useSelector((state) => state.collapsed);
    const currentPath = useSelector((state) => state.currentPath);
    const dispatch = useDispatch();
    const logout = () => {
      dispatch({
        type: "LOGOUT",
      });
    };
  
    const toggle = () => {
      dispatch({
        type: "TOGGLE",
      });
    };
    const showLoading = () => {
      dispatch({
        type: "SHOWLOADDING",
      });
    };
  
    const hideLoading = () => {
      dispatch({
        type: "HIDELOADDING",
      });
    };
    const setCurrentPath = (data)=>{
      dispatch({
        type:'SETCURRENTPATH',
        payload:data
      })
    }
  
  
    return {
      userData,
      currentPath,
      loading,
      collapsed,
      logout,
      toggle,
      showLoading,
      hideLoading,
      setCurrentPath
    };
  };
  
  export default useStore;